<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>自定义全局指令</title>
</head>

<body>
    <div id="app">
        <!-- 无参数 -->
        <input type="text" v-focus>
        <input type="text">
    </div>

    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        Vue.directive('focus', {
            inserted: function (el) {
                // el表示指令所绑定的元素
                el.focus();
            }
        });
        var vm = new Vue({
            el: '#app',
            data: {

            }
        });
    </script>
</body>

</html>